<template>
  <div class="rightList">
    <!-- 面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 权限数据列表 -->
    <el-table :data="rightList" height="750" border style="width: 50%">
      <el-table-column type="index" width="50"></el-table-column>
      <el-table-column prop="authName" label="权限名称" ></el-table-column>
      <el-table-column prop="path" label="路径" ></el-table-column>
      <el-table-column prop="level" label="层级">
          <template slot-scope="scope">
              {{scope.row.level | levelFormat(scope.row.level)}}
          </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getAllRightList } from '@/api/right_api.js'
export default {
  data () {
    return {
      rightList: []
    }
  },
  mounted () {
    getAllRightList('list')
      .then(res => {
        if (res.data.meta.status === 200) {
          console.log(res, 'getAllRightList')
          this.rightList = res.data.data
        }
      })
      .catch(err => {
        console.log(err)
      })
  },
  filters: {
    levelFormat: (level) => {
      if (level === '0') {
        level = '一级'
      } else if (level === '1') {
        level = '二级'
      } else if (level === '2') {
        level = '三级'
      }
      return level
    }
  }
}
</script>

<style lang="less" scoped>
</style>
